//原始类型
let boole: boolean = true;
let num: number | undefined | null = 123;
let str: string = 'abc';

// str = 1; error

//数组
let arr1: number[] = [1, 2, 3];
let arr2: Array<number | string> = [1, 2, 3, '4'];

//元组
let tuple: [number, string] = [1, '2'];
tuple.push('2');
// console.log(tuple);
// tuple[2];

//函数
let add = (x: number, y: number) => x + y;
let compute: (x: number, y: number) => number;
compute = (a, b) => a + b;

//对象
let obj: { x: number, y: number } = {
    x: 1,
    y: 2
};
obj.x = 3;

//symbol

//undefined, null
let un: undefined = undefined;
let nu: null = null;
num = undefined;
num = nu;

//void
let noReturn = () => { };

//any
let x;
x = 1;
x = '2';
x = () => { };

//never
let error = () => {throw new Error("error")};

let endless = () => {
    while(true){}
}
